﻿/*
 * This software is the confidential and proprietary
 * information of NetBay
 * Such confidential information should not be disclosed
 * NetBay copyright(c) 2010
 */

#region Using
using System.Globalization;
using System.Reflection;
using NetBay.Core.Globalization;
#endregion

namespace Rio.Framework.RioManager
{
    /// <summary>
    /// Handle the localization 
    /// </summary>
    public static class LanguageManager
    {
        #region Enums
        #endregion

        #region Constants
        /// <summary>
        /// Namespace of resource
        /// </summary>
        const string LANGUAGE_LOCALIZATION_FILE_NAME = "Rio.Framework.RioManager.LocalizationFile.RioLocalization";
        #endregion

        #region Attributes
        /// <summary>
        /// Manager of globalisation of .NET assembly
        /// </summary>
        private static GlobalizationManager m_oGlobalizationManager;
        #endregion

        #region Init
        /// <summary>
        /// Initialize the LanguageManager class
        /// </summary>
        /// <param name="p_sCulture">culture requested</param>
        internal static void Init(string p_sCulture)
        {
            CultureInfo L_cultureInfo;
            if (p_sCulture.Equals(string.Empty))
            {
                L_cultureInfo = CultureInfo.CurrentCulture;
            }
            else
            {
                L_cultureInfo = new CultureInfo(p_sCulture);
            }

            m_oGlobalizationManager = new GlobalizationManager();
            m_oGlobalizationManager.CurrentCultureInfo = L_cultureInfo;
            m_oGlobalizationManager.ReferenceAssembly = Assembly.Load(AssemblyName.GetAssemblyName(Assembly.GetExecutingAssembly().Location));
            m_oGlobalizationManager.ResourceNamespace = LANGUAGE_LOCALIZATION_FILE_NAME;
        }
        #endregion


        #region Functions

        #region Publics

        /// <summary>
        /// Retreive the string localized
        /// </summary>
        /// <param name="p_sName">string's name</param>
        /// <param name="p_sCulture"></param>
        /// <returns>string localized</returns>
        public static string GetString(string p_sName, string p_sCulture)
        {
            Init(p_sCulture);
            string l_sTempName = m_oGlobalizationManager.GetString(p_sName);
            if (l_sTempName == null)
            {
                l_sTempName = string.Empty;
            }
            return l_sTempName;
        }
        #endregion

        #region Privates
        #endregion

        #endregion
    }
}
